package com.topcoder.srm511;

import java.util.Arrays;

public class Zoo {
	public long theCount(int[] answers) {
		Arrays.sort(answers);
		int N = answers.length;
		int a = answers[N-1] + 1;
		int b = N - a;
		if (a < 0 || b < 0) return 0;
		
		for (int i=0; i<b; i++) {
			if (answers[2*i] != i || answers[2*i + 1] != i) return 0;
		}
		
		for (int i=0; i<a-b; i++) {
			if (answers[2*b + i] != b+i) return 0;
		}
		
		long s = 1;
		for (int i=0; i<b; i++) s *= 2;
		
		return a==b? s : 2*s;
	}
}
